package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.distributor.dto.DistributorCommunicateDeleteBatchDTO;
import com.xbongbong.distributor.vo.DistributorCommunicateDeleteBatchVO;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.CallCommunicateDTO;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataGetDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.customer.pojo.dto.CustomerRestoreBatchDTO;
import com.xbongbong.pro.customercommunicate.pojo.dto.CustomerCommunicateDeleteBatchDTO;
import com.xbongbong.pro.customercommunicate.pojo.dto.CustomerCommunicateInsertBatchDTO;
import com.xbongbong.pro.customercommunicate.pojo.dto.CustomerCommunicateUpdateBatchDTO;
import com.xbongbong.pro.customercommunicate.pojo.dto.CustomerCommunicateUpdateByBusinessRuleDTO;
import com.xbongbong.pro.customercommunicate.pojo.dto.CustomerDynamicAddDTO;
import com.xbongbong.pro.customercommunicate.pojo.vo.CommunicatePermissionVO;
import com.xbongbong.pro.customercommunicate.pojo.vo.CustomerCommunicateDeleteBatchVO;
import com.xbongbong.pro.customercommunicate.pojo.vo.CustomerCommunicateInsertBatchVO;
import com.xbongbong.pro.customercommunicate.pojo.vo.CustomerCommunicateUpdateBatchVO;
import com.xbongbong.pro.customercommunicate.pojo.vo.CustomerCommunicateUpdateByBusinessRuleVO;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainInLinkItemDTO;
import com.xbongbong.pro.webdetail.pojo.vo.CommunicateDetailVO;
import com.xbongbong.pro.weblist.pojo.vo.CommunicateVO;

import java.util.List;
import java.util.Map;

/**
 * 经销商跟进记录
 * @author xinpeng.jiang
 * @date 2020/12/30 10:05
 * @version 1.0
 * @since V1.0
 */
public interface DistributorCommunicateService {
    /**
     * Description: 客户跟进记录保存前校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @throws XbbException 业务异常
     * @author long.rao
     * @date 2019-01-22 10:34
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * Description: 客户跟进记录保存后逻辑
     *
     * @param saasFormSaveDTO saas保存数据
     * @throws XbbException 业务异常
     * @author long.rao
     * @date 2019-01-22 10:34
     */
    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    /**
     * 跟进记录列表
     *
     * @param formDataListDTO 参数
     * @return 列表
     * @throws XbbException 业务异常
     */
    CommunicateVO list(FormDataListDTO formDataListDTO) throws XbbException;

    /**
     * 新建时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-02-13 20:53
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 编辑时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-02-13 20:53
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 客户跟进记录详情
     *
     * @param formDataGetDTO 参数
     * @return CommunicateDetailVO
     */
    CommunicateDetailVO detail(FormDataGetDTO formDataGetDTO) throws XbbException;

    /**
     * 根据业务规则修改数据
     *
     * @param update 更新参数
     * @return UpdateCustomerCommunicateByBusinessRuleVO
     * @throws XbbException 业务异常
     * @author 吴峰
     * @date 2019/2/17 14:53
     */
    CustomerCommunicateUpdateByBusinessRuleVO updateFormDataByBusinessRule(CustomerCommunicateUpdateByBusinessRuleDTO update) throws XbbException;

    /**
     * 通话记录同步到客户跟进记录
     *
     * @param callCommunicateDTO 通话记录同步到客户跟进记录入参
     * @throws XbbException XbbException
     */
    void autoAfterCallCommunicate(CallCommunicateDTO callCommunicateDTO) throws XbbException;

    /**
     * 批量删除
     *
     * @param distributorCommunicateDeleteBatchDTO
     * @return com.xbongbong.pro.customercommunicate.pojo.vo.CustomerCommunicateDeleteBatchVO
     * @throws XbbException 业务异常
     * @author 吴峰
     * @date 2019/3/14 18:47
     */
    DistributorCommunicateDeleteBatchVO deleteBatch(DistributorCommunicateDeleteBatchDTO distributorCommunicateDeleteBatchDTO) throws XbbException;

    /**
     * 批量添加
     *
     * @param insertBatchDTO
     * @return com.xbongbong.pro.customercommunicate.pojo.vo.CustomerCommunicateInsertBatchVO
     * @throws XbbException 业务异常
     * @author 吴峰
     * @date 2019/3/19 20:04
     */
    CustomerCommunicateInsertBatchVO insertBatch(CustomerCommunicateInsertBatchDTO insertBatchDTO) throws XbbException;


    /**
     * 获取客户的跟进记录
     *
     * @param corpid     公司id
     * @param customerId 客户id
     * @return List
     * @author GuoJun.HU
     * @date 2019/4/11 11:10
     * @since V1.0
     */
    List<PaasFormDataEntityExt> getCustomerCommunicateEsDataListByCustomerId(String corpid, Long customerId) throws XbbException;

    /**
     * 关联新建格式化解释
     *
     * @param handlerExplainInLinkItemDTO 入参
     * @throws XbbException 异常
     */
    void formatLinkAddExplain(HandlerExplainInLinkItemDTO handlerExplainInLinkItemDTO) throws XbbException;

    /**
     * 判断是否有跟进记录创建权限等
     * @param baseDTO
     * @return com.xbongbong.pro.customercommunicate.pojo.vo.CommunicatePermissionVO
     * @throws XbbException
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    CommunicatePermissionVO permission(BaseDTO baseDTO) throws XbbException;

    /**
     * 将Excel数据格式化成表单保存需要的JSON格式的数据
     *
     * @param importFormDataDTO 导入入参
     * @param titlePojoList     标题
     * @param rowGroupPojo      一个表单对应的一组Excel填写的数据
     * @param fieldAttrList     解释
     * @return FormDataAddDTO
     * @throws XbbException XbbException
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    void setCondition(FormDataListDTO formDataListDTO) throws XbbException;
    /**
     * Description: 数据一致性同步
     * @param corpid
     * @param customerId
     * @param customerName
     * @author 魏荣杰
     * @date 2019/6/11 19:01
     * @since v1.0
     */
    void dataConsistencyUpdateCustomer(String corpid, Long customerId, String customerName) throws XbbException;
    /**
     * Description: 批量更新
     * @param customerCommunicateUpdateBatchDTO
     * @return com.xbongbong.pro.customercommunicate.pojo.vo.CustomerCommunicateUpdateBatchVO
     * @author 魏荣杰
     * @date 2019/6/11 19:00
     * @since v1.0
     */
    CustomerCommunicateUpdateBatchVO updateBatch(CustomerCommunicateUpdateBatchDTO customerCommunicateUpdateBatchDTO) throws XbbException;
    /**
     * Description: 数据一致性同步
     * @param corpid
     * @param dataId 数据id
     * @param businessType 跟进记录存储的关联业务类型
     * @param serialNo 存储的编号
     * @author 魏荣杰
     * @date 2019/6/11 19:01
     * @since v1.0
     */
    void dataConsistencyUpdateLinkBusiness(String corpid, Long dataId, String serialNo, Integer businessType) throws XbbException;

    /**
     * 客户动态（项目日志）添加
     * @param customerDynamicAddDTO 入参
     * @throws XbbException xbbException
     */
    void addCustomerDynamic(CustomerDynamicAddDTO customerDynamicAddDTO) throws XbbException;

    /**
     * 客户动态（项目日志）添加
     * @param corpid 公司id
     * @param userId 用户userId
     * @param memo 备注
     * @param customerId 客户id
     * @param customerName 客户名称
     * @param logType  项目日志类型
     * @throws XbbException xbbException
     */
    void addCustomerDynamic(String corpid,String userId,String memo,Long customerId,String customerName,Integer logType) throws XbbException;

    /**
     *  客户动态（项目日志）批量添加
     * @param list 入参
     * @param corpid 公司id
     */
    void batchAddCustomerDynamic(List<CustomerDynamicAddDTO> list,String corpid) throws XbbException;

    /**
     * 更新回滚
     * @param idIn
     * @param corpid
     * @throws XbbException
     */
    void updateRollback(List<Long> idIn, String corpid) throws XbbException;

    /**
     * 还原数据
     * @author xingxing.xiao
     */
    void restoreBatch(String corpid, Map<Long, Long> customerUpdateTimeMap, CustomerRestoreBatchDTO customerRestoreBatchDTO) throws XbbException;

    /**
     * 新建跟进记录推送消息
     * @param loginUser 登录用户
     * @param businessType 业务类型
     * @param corpid 企业ID
     * @param atUserIds @指定人员ID
     * @param paasFormDataEntity 数据实体
     * @param dataId 数据实体ID
     * @throws XbbException 异常信息
     * @author JianTao.Xiong
     */
    void pushCustomerCommounicate(UserVO loginUser, Integer businessType, String corpid, List<String> atUserIds, PaasFormDataEntity paasFormDataEntity, Long dataId) throws XbbException;

    }
